﻿
Imports System.Linq

Public Class UserRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function GetUserById(ByVal id As Integer) As tblUser
        Dim user = dc.tblUsers.SingleOrDefault(Function(p As tblUser) p.ID_User = id)
        Return user
    End Function

    Public Function GetUser(ByVal username As String, ByVal pass_md5 As String) As tblUser
        Dim user = dc.tblUsers.SingleOrDefault(Function(p As tblUser) p.UserName = username And p.Password = pass_md5)
        Return user
    End Function

    Public Sub Insert(ByVal obj As tblUser)
        dc.tblUsers.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

End Class
